package com.bm.web.servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.bm.entity.product;
import com.bm.service.ImgService;
import com.bm.service.impl.ImgServiceImpl;

/**
 * Servlet implementation class FirstWebServlet
 */
@WebServlet("/FirstWebServlet")
public class FirstWebServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public FirstWebServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		request.setCharacterEncoding("UTF-8");
		String id = request.getParameter("productId");
		HttpSession session = request.getSession();
	  	String type = request.getParameter("name");
		ImgService imgservice = new ImgServiceImpl();
		product product = new product();

		if(id.equals("10-1")) {
			List<product> listProductPath = new ArrayList<product>();
			product product1 = new product("image/奢石系列/59bbbba1-6afa-410d-8627-49bde5b4622a.jpg","绵阳水磨石砖-奢石系列","产品中心");
			product product2 = new product("image/爆款灰色系列/4946dbcb-16d8-4418-aef5-9609f684093c.jpg","成都水磨石-爆款灰色系列","产品中心");
			product product3 = new product("image/五彩石系列/953e84c9-a1e4-4a2a-874a-57c95ab32d69.jpg","南充水磨石砖-五彩石系列","产品中心");
			product product4 = new product("image/黑色系列/aa4f0035-51a9-44e1-850b-74f30fbe7ab1.jpg","重庆水磨石砖-黑色系列","产品中心");
			product product5 = new product("image/白底黑石子系列/8a1f7033-2f43-4fc6-8ff5-320497f13029.jpg","宜宾水磨石砖-白底黑石子系列","产品中心");
			product product6 = new product("image/奢石系列/3f26bbd7-0854-40c8-8fd0-55165686a9db.jpg","四川水磨石砖-奢石系列","产品中心");
			product product7 = new product("image/白色系列/6678befd-5162-41aa-b933-112558b849ff.jpg","白色系列水磨石砖","产品中心");
			product product8 = new product("image/奢石系列/302d39f2-7bdf-46a7-9cae-a925e40dbbdd.jpg","贵州水磨石砖厂家","产品中心");
			product product9 = new product("image/爆款灰色系列/66e44fd2-6ff1-4b8f-ad6a-be442f58db9f.jpg","广汉水磨石砖批发-化石灰系列","产品中心");
			product product10 = new product("image/奢石系列/aae35419-b7ca-4708-baac-54ebd921992b.jpg","自贡水磨石砖定制","产品中心");
			listProductPath.add(product1);
			listProductPath.add(product2);
			listProductPath.add(product3);
			listProductPath.add(product4);
			listProductPath.add(product5);
			listProductPath.add(product6);
			listProductPath.add(product7);
			listProductPath.add(product8);
			listProductPath.add(product9);
			listProductPath.add(product10);
			
			request.setAttribute("list", listProductPath);
		}
			if(!id.equals("10-1")) {
				List<product> list = imgservice.selectPhotoPath(id);
				List<product> listProductPath = new ArrayList<product>();
				for(int i=0;i<list.size();i++) {
					listProductPath.add(list.get(i));
				}	
				request.setAttribute("list", listProductPath);
			}
			request.getRequestDispatcher("publicShowTenDiv.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
